<?php
namespace App\Modules\App;
use App\Modules\AdapterApi;
use App\Services\User\UserIndex;

class App extends AdapterApi
{
    // 增加一个app应用
    public function add(): array
    {
        $data = pick_array($this->postData,['name','allow_role_ids']);

        return UserIndex::App()->add($data);
    }
    // 禁用一个应用
    public function stop(): array
    {
        $data = pick_array($this->postData,['id','name','app_key']);

        return UserIndex::App()->stop($data);
    }
    // 查看所有应用
    public function list(): array
    {
        $data = pick_array($this->postData,['page','list_rows','status']);

        return UserIndex::App()->list($data);
    }
    // 查看某一应用的信息
    public function find(): array
    {
        $data = pick_array($this->postData,['id','name','app_key']);

        return UserIndex::App()->find($data);
    }
    // 为一个应用增加可以访问的角色
    public function addRoles(): array
    {
        $data = pick_array($this->postData,['id','name','allow_role_ids']);

       return UserIndex::App()->addRoles($data);
    }
    // 为一个应用增加可以访问的角色
    public function removeRoles(): array
    {
        $data = pick_array($this->postData,['id','name','allow_role_ids']);

        return UserIndex::App()->removeRoles($data);
    }
    // 启用某一应用的信息
    public function start(): array
    {
        $data = pick_array($this->postData,['id','name','app_key']);

        return UserIndex::App()->start($data);
    }
    // 编辑某一应用的信息
    public function edit(): array
    {
        $data = pick_array($this->postData,['id','name','allow_role_ids']);

        return UserIndex::App()->edit($data);
    }
    // 查看所有应用不分页
    public function all(): array
    {
        return UserIndex::App()->all();
        return $this->oneStepRun([], 'serveruser/auth/App/all', 'all');
    }
    // 根据app_ids获取app_name
    public function getAppNameByIds(): array
    {
        $data = pick_array($this->postData,['app_ids']);

        return UserIndex::App()->getAppNameByIds($data);
    }
}